const path = require('path');
const { merge } = require('webpack-merge');
const webpack = require('webpack');
const commonWebpackConfig = require('./webpack.common.js');
const ESLintPlugin = require('eslint-webpack-plugin');

let config =  merge(commonWebpackConfig,{
    mode: "development",
    devtool: 'eval-cheap-module-source-map',
    devServer: {
        contentBase: './dist',//本地服务器所加载的页面所在的目录
        stats:"errors-only",
        host:"localhost",
        port:9999,
        compress:true,//一切服务都启用 gzip 压缩
        hot:true,//启用webpack的热模块替换功能
        inline: true,//实时刷新
        historyApiFallback:true
    },
    module: {
        rules: [
            {
                test: /\.less$/,
                use:['vue-style-loader','style-loader', 'css-loader', 'less-loader']
            },
            {
                test: /\.css$/,
                use: ['vue-style-loader','style-loader', 'css-loader']
            },
            // {
            //     test: /\.js$/,
            //     exclude: /node_modules/,
            //     loader: "eslint-loader",
            //     enforce: "pre"
            // }
        ]
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new webpack.DefinePlugin({
            BASE_URL: JSON.stringify('development')
        }),
        new ESLintPlugin()
    ]
});



module.exports = config;